<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Simple Framework: Assets/Scripts/Core/UIManager.cs 源文件</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="logo.gif"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Simple Framework
   &#160;<span id="projectnumber">v0.1.1</span>
   </div>
   <div id="projectbrief">A simple Unity application framework</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'搜索');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','搜索');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('_u_i_manager_8cs_source.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">UIManager.cs</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="keyword">using</span> <a class="code" href="namespace_system.html">System</a>.Collections.Generic;</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="keyword">using</span> <a class="code" href="namespace_framework.html">Framework</a>.<a class="code" href="namespace_framework_1_1_utilities.html">Utilities</a>;</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="keyword">using</span> <a class="code" href="namespace_unity_engine.html">UnityEngine</a>;</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;</div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespace_framework.html">Framework</a>.Core</div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;{</div><div class="line"><a name="l00010"></a><span class="lineno"><a class="line" href="class_framework_1_1_core_1_1_u_i_manager.html">   10</a></span>&#160;    <span class="keyword">public</span> <span class="keyword">class </span><a class="code" href="class_framework_1_1_core_1_1_u_i_manager.html">UIManager</a> : <a class="code" href="class_framework_1_1_utilities_1_1_mono_singleton.html">MonoSingleton</a>&lt;UIManager&gt;</div><div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;    {</div><div class="line"><a name="l00015"></a><span class="lineno"><a class="line" href="class_framework_1_1_core_1_1_u_i_manager.html#a3c52cf79bad5e6cf831041777d11ac9a">   15</a></span>&#160;        <span class="keyword">public</span> readonly <span class="keywordtype">string</span> FoldPath = <span class="stringliteral">&quot;Prefabs/UI/&quot;</span>;</div><div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;</div><div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;        <span class="keyword">private</span> readonly List&lt;Transform&gt; _panels = <span class="keyword">new</span> List&lt;Transform&gt;();</div><div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;</div><div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;        <span class="keyword">private</span> readonly List&lt;KeyValuePair&lt;string, UIBase&gt;&gt; _openUI = <span class="keyword">new</span> List&lt;KeyValuePair&lt;string, UIBase&gt;&gt;();</div><div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;</div><div class="line"><a name="l00034"></a><span class="lineno"><a class="line" href="class_framework_1_1_core_1_1_u_i_manager.html#a7424ddb34cb4b3637f78abe7df32ab10">   34</a></span>&#160;        <span class="keyword">public</span> <a class="code" href="class_framework_1_1_core_1_1_u_i_base.html">UIBase</a> <a class="code" href="class_framework_1_1_core_1_1_u_i_manager.html#a7424ddb34cb4b3637f78abe7df32ab10">Open</a>(<span class="keywordtype">string</span> uiName, <span class="keywordtype">int</span> layer = 1, <span class="keywordtype">object</span> args = null)</div><div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;        {</div><div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;            <span class="comment">//实例化UI</span></div><div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;            GameObject ui = <a class="code" href="class_framework_1_1_core_1_1_resource_manager.html">ResourceManager</a>.<a class="code" href="class_framework_1_1_utilities_1_1_singleton.html#a3e8f42f51188ce789d8eceba2717356d">Instance</a>.Instantiate(FoldPath + uiName, _panels[layer]);</div><div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;</div><div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;            <span class="comment">//添加到UI键值对列表</span></div><div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;            _openUI.Add(<span class="keyword">new</span> KeyValuePair&lt;string, UIBase&gt;(uiName, ui.GetComponent&lt;<a class="code" href="class_framework_1_1_core_1_1_u_i_base.html">UIBase</a>&gt;()));</div><div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;</div><div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;            <span class="comment">//启动参数</span></div><div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;            ui.GetComponent&lt;<a class="code" href="class_framework_1_1_core_1_1_u_i_base.html">UIBase</a>&gt;().OnDisplay(args);</div><div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;            ui.GetComponent&lt;<a class="code" href="class_framework_1_1_core_1_1_u_i_base.html">UIBase</a>&gt;().OnRegisterHandler();</div><div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;</div><div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;            <span class="keywordflow">return</span> ui.GetComponent&lt;<a class="code" href="class_framework_1_1_core_1_1_u_i_base.html">UIBase</a>&gt;();</div><div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;        }</div><div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;</div><div class="line"><a name="l00053"></a><span class="lineno"><a class="line" href="class_framework_1_1_core_1_1_u_i_manager.html#acd70915d9853c34c9dfdaa91d533228a">   53</a></span>&#160;        <span class="keyword">public</span> <span class="keywordtype">void</span> <a class="code" href="class_framework_1_1_core_1_1_u_i_manager.html#acd70915d9853c34c9dfdaa91d533228a">Close</a>(<span class="keywordtype">string</span> uiName)</div><div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;        {</div><div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;            <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = _openUI.Count - 1; i &gt;= 0; i--)</div><div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;            {</div><div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;                <span class="keywordflow">if</span> (_openUI[i].Key == uiName)</div><div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;                {</div><div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;                    CloseUI(_openUI[i].Value);</div><div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;                    _openUI.RemoveAt(i);</div><div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;                    <span class="keywordflow">break</span>;</div><div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;                }</div><div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;            }</div><div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;        }</div><div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;</div><div class="line"><a name="l00070"></a><span class="lineno"><a class="line" href="class_framework_1_1_core_1_1_u_i_manager.html#ae465fba1fe8210a6a5c499bca8e4a0dc">   70</a></span>&#160;        <span class="keyword">public</span> <span class="keywordtype">void</span> <a class="code" href="class_framework_1_1_core_1_1_u_i_manager.html#ae465fba1fe8210a6a5c499bca8e4a0dc">Close</a>(<a class="code" href="class_framework_1_1_core_1_1_u_i_base.html">UIBase</a> ui)</div><div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;        {</div><div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;            <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = _openUI.Count - 1; i &gt;= 0; i--)</div><div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;            {</div><div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;                <span class="keywordflow">if</span> (_openUI[i].Value == ui)</div><div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;                {</div><div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;                    CloseUI(_openUI[i].Value);</div><div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;                    _openUI.RemoveAt(i);</div><div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;                    <span class="keywordflow">break</span>;</div><div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;                }</div><div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;            }</div><div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;        }</div><div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;</div><div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;        <span class="keyword">private</span> <span class="keywordtype">void</span> CloseUI(<a class="code" href="class_framework_1_1_core_1_1_u_i_base.html">UIBase</a> ui)</div><div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;        {</div><div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;            ui.<a class="code" href="class_framework_1_1_core_1_1_u_i_base.html#ae1b8d8a3f68c2119ff6e9099b14d0f87">OnClose</a>();</div><div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;            Destroy(ui.gameObject);</div><div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;        }</div><div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;</div><div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;        <span class="comment">// Use this for initialization</span></div><div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;        <span class="keyword">private</span> <span class="keywordtype">void</span> Awake()</div><div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;        {</div><div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;            <span class="comment">//收集所有子对象</span></div><div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;            <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; transform.childCount; i++)</div><div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;            {</div><div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;                _panels.Add(transform.GetChild(i));</div><div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;                <span class="comment">//销毁现有的UI预设</span></div><div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;                <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = _panels[i].childCount - 1; j &gt;= 0; j--)</div><div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;                {</div><div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;                    Destroy(_panels[i].GetChild(j).gameObject);</div><div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;                }</div><div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;            }</div><div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;        }</div><div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;    }</div><div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;}</div><div class="ttc" id="class_framework_1_1_core_1_1_u_i_base_html"><div class="ttname"><a href="class_framework_1_1_core_1_1_u_i_base.html">Framework.Core.UIBase</a></div><div class="ttdoc">所有UI父对象的基类。 </div><div class="ttdef"><b>Definition:</b> <a href="_u_i_base_8cs_source.html#l00011">UIBase.cs:11</a></div></div>
<div class="ttc" id="class_framework_1_1_core_1_1_u_i_manager_html"><div class="ttname"><a href="class_framework_1_1_core_1_1_u_i_manager.html">Framework.Core.UIManager</a></div><div class="ttdoc">界面管理，提供管理界面和界面组的功能，如显示隐藏界面、激活界面。 </div><div class="ttdef"><b>Definition:</b> <a href="_u_i_manager_8cs_source.html#l00010">UIManager.cs:10</a></div></div>
<div class="ttc" id="namespace_system_html"><div class="ttname"><a href="namespace_system.html">System</a></div></div>
<div class="ttc" id="namespace_framework_1_1_utilities_html"><div class="ttname"><a href="namespace_framework_1_1_utilities.html">Framework.Utilities</a></div><div class="ttdef"><b>Definition:</b> <a href="_localization_8cs_source.html#l00008">Localization.cs:8</a></div></div>
<div class="ttc" id="class_framework_1_1_core_1_1_u_i_base_html_ae1b8d8a3f68c2119ff6e9099b14d0f87"><div class="ttname"><a href="class_framework_1_1_core_1_1_u_i_base.html#ae1b8d8a3f68c2119ff6e9099b14d0f87">Framework.Core.UIBase.OnClose</a></div><div class="ttdeci">virtual void OnClose()</div><div class="ttdoc">当关闭时执行。 </div><div class="ttdef"><b>Definition:</b> <a href="_u_i_base_8cs_source.html#l00033">UIBase.cs:33</a></div></div>
<div class="ttc" id="class_framework_1_1_utilities_1_1_mono_singleton_html"><div class="ttname"><a href="class_framework_1_1_utilities_1_1_mono_singleton.html">Framework.Utilities.MonoSingleton</a></div><div class="ttdoc">单例的MonoBehaviour。 </div><div class="ttdef"><b>Definition:</b> <a href="_singleton_8cs_source.html#l00055">Singleton.cs:55</a></div></div>
<div class="ttc" id="class_framework_1_1_core_1_1_u_i_manager_html_acd70915d9853c34c9dfdaa91d533228a"><div class="ttname"><a href="class_framework_1_1_core_1_1_u_i_manager.html#acd70915d9853c34c9dfdaa91d533228a">Framework.Core.UIManager.Close</a></div><div class="ttdeci">void Close(string uiName)</div><div class="ttdoc">关闭指定名称的UI，是从后往前查找。 </div><div class="ttdef"><b>Definition:</b> <a href="_u_i_manager_8cs_source.html#l00053">UIManager.cs:53</a></div></div>
<div class="ttc" id="class_framework_1_1_core_1_1_u_i_manager_html_ae465fba1fe8210a6a5c499bca8e4a0dc"><div class="ttname"><a href="class_framework_1_1_core_1_1_u_i_manager.html#ae465fba1fe8210a6a5c499bca8e4a0dc">Framework.Core.UIManager.Close</a></div><div class="ttdeci">void Close(UIBase ui)</div><div class="ttdoc">关闭指定UI对象。 </div><div class="ttdef"><b>Definition:</b> <a href="_u_i_manager_8cs_source.html#l00070">UIManager.cs:70</a></div></div>
<div class="ttc" id="namespace_framework_html"><div class="ttname"><a href="namespace_framework.html">Framework</a></div></div>
<div class="ttc" id="class_framework_1_1_core_1_1_u_i_manager_html_a7424ddb34cb4b3637f78abe7df32ab10"><div class="ttname"><a href="class_framework_1_1_core_1_1_u_i_manager.html#a7424ddb34cb4b3637f78abe7df32ab10">Framework.Core.UIManager.Open</a></div><div class="ttdeci">UIBase Open(string uiName, int layer=1, object args=null)</div><div class="ttdoc">打开一个UI。 </div><div class="ttdef"><b>Definition:</b> <a href="_u_i_manager_8cs_source.html#l00034">UIManager.cs:34</a></div></div>
<div class="ttc" id="class_framework_1_1_utilities_1_1_singleton_html_a3e8f42f51188ce789d8eceba2717356d"><div class="ttname"><a href="class_framework_1_1_utilities_1_1_singleton.html#a3e8f42f51188ce789d8eceba2717356d">Framework.Utilities.Singleton.Instance</a></div><div class="ttdeci">static T Instance</div><div class="ttdoc">实例 </div><div class="ttdef"><b>Definition:</b> <a href="_singleton_8cs_source.html#l00020">Singleton.cs:20</a></div></div>
<div class="ttc" id="namespace_unity_engine_html"><div class="ttname"><a href="namespace_unity_engine.html">UnityEngine</a></div></div>
<div class="ttc" id="class_framework_1_1_core_1_1_resource_manager_html"><div class="ttname"><a href="class_framework_1_1_core_1_1_resource_manager.html">Framework.Core.ResourceManager</a></div><div class="ttdoc">资源管理，提供各项本地资源，包括物体对象和UI等的解码和加载功能。 </div><div class="ttdef"><b>Definition:</b> <a href="_resource_manager_8cs_source.html#l00011">ResourceManager.cs:11</a></div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_84bbf7b3c7f28a5a18725745e1505219.html">Assets</a></li><li class="navelem"><a class="el" href="dir_f13b41af88cf68434578284aaf699e39.html">Scripts</a></li><li class="navelem"><a class="el" href="dir_7db68f476bd50f9f6d9cf398af037e8e.html">Core</a></li><li class="navelem"><b>UIManager.cs</b></li>
    <li class="footer">制作者
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.13 </li>
  </ul>
</div>
</body>
</html>
